#include <func.h>

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        puts("main filename");
        return -1;
    }
    DIR *pd = opendir(argv[1]);
    if (pd == NULL)
    {
        perror("opendir");
        return -1;
    }
    struct dirent* p;
    off_t flag;
    while (p = readdir(pd))
    {
        printf("name: %-10s len: %-5d type: %5d \n",p->d_name, p->d_reclen, p->d_type);
    }
    rewinddir(pd);
    p = readdir(pd);
    printf("name: %-10s len: %-5d type: %5d \n",p->d_name, p->d_reclen, p->d_type);
    closedir(pd);
	return 0;
}
